﻿using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using ChBusiness.Common;


/// <summary>
/// ajaxService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class ajaxService : System.Web.Services.WebService
{

    public ajaxService()
    {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    /// <summary>
    /// 返回街道
    /// </summary>
    /// <returns></returns>
    [WebMethod]
    public string GetStreet(string strArea)
    {
        DataCollectQuery collectQuery = new DataCollectQuery();
        DataTable dt = collectQuery.GetSteet(strArea);
        string html = "<select name='ddlstreet' id='ddlstreet' onchange='ChangeAppear()'  style='width:114px'>";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            html += string.Format("\n<option value='{0}'>{0}</option>",dt.Rows[i]["street_name"]);
        }
        return html + " </select>";
    }

    /// <summary>
    /// 返回街道
    /// </summary>
    /// <returns></returns>
    [WebMethod]
    public string[] GetStreets(string strArea,string selid,string hidid,string containerId)
    {
        DataCollectQuery collectQuery = new DataCollectQuery();
        DataTable dt = collectQuery.GetSteet(strArea);
        string[] html = new string[3];
        html[0] = string.Format("<select name='{0}' id='{0}' style='width:60px' onchange='SetHidden(this,\"{1}\");' onclick='javascript:IsFirst=false;'>", selid, hidid);
        html[0] += string.Format("<option value='{0}'>{0}</option>", "");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            html[0] += string.Format("\n<option value='{0}'>{0}</option>", dt.Rows[i]["street_name"]);
        }
        html[0] += " </select>\r\n";
        html[1] = containerId;
        html[2] = selid;
        return html;
    }
}

